package com.xijing.view;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.*;


import java.text.SimpleDateFormat;




public class MainFrame extends JFrame implements ActionListener{
	
	JMenuBar mainBar;
	JMenu rmMenu,bmMenu,siMenu,sMenu,smMenu;
	JMenuItem ciItem,cumItem,coItem,bkItem,bconItem,bcelItem,brItem,
					  clItem,rtItem,riItem,rsItem,cirItem,crItem,upItem,exitItem;
	public static JPanel rmPanel,bmPanel,siPanel,sPanel,smPanel,selectPanel;
	JButton rmButton,bmButton,siButton,sButton,smButton,
			   ciButton,cumButton,coButton,bkButton,bconButton,bcelButton,brButton,
			   clButton,rtButton,riButton,rsButton,cirButton,crButton,upButton,exitButton;
	static Label timeLabel;
	String rmButtonIcon="picPackage/rmButtonIcon.png",
			  bmButtonIcon="picPackage/bmButtonIcon.png",
		      siButtonIcon="picPackage/siButtonIcon.png",
		      sButtonIcon="picPackage/sButtonIcon.png",
		      smButtonIcon="picPackage/smButtonIcon.png",
	 		  ciButtonIcon="picPackage/ciButtonIcon.png",
	 		  cumButtonIcon="picPackage/cumButtonIcon.png",
	 		  coButtonIcon="picPackage/coButtonIcon.png",
	 		  bkButtonIcon="picPackage/bkButtonIcon.png",
	 		  bconButtonIcon="picPackage/bconButtonIcon.png",
	 		  bcelButtonIcon="picPackage/bcelButtonIcon.png",
	 		  brButtonIcon="picPackage/brButtonIcon.png",
	 		  clButtonIcon="picPackage/clButtonIcon.png",
	 		  rtButtonIcon="picPackage/rtButtonIcon.png",
	 		  riButtonIcon="picPackage/riButtonIcon.png",
	 		  rsButtonIcon="picPackage/rsButtonIcon.png",
	 		  cirButtonIcon="picPackage/cirButtonIcon.png",
	 		  crButtonIcon="picPackage/crButtonIcon.png",
	 		  upButtonIcon="picPackage/upButtonIcon.png",
	 		  exitButtonIcon="picPackage/exitButtonIcon.png";
	
	JLabel rmLabel,bmLabel,siLabel,sLabel,smLabel,
			  ciLabel,cumLabel,coLabel,bkLabel,bconLabel,bcelLabel,brLabel,
			  clLabel,rtLabel,riLabel,rsLabel,cirLabel,crLabel,upLabel,exitLabel;
	
	MainFrame(){
		setTitle("宾馆管理系统");
		setBounds(150,50,1000,700);
		setBackground(Color.white);
		
		setResizable(false);
		mainBar=new JMenuBar();
		this.setJMenuBar(mainBar);
		setLayout(null);
		selectPanel=new JPanel();
		selectPanel.setLayout(null);
		selectPanel.setVisible(true);
		selectPanel.setBounds(100,60,200,500);
		selectPanel.setBackground(Color.ORANGE);
		
		rmPanel=new JPanel();
		rmPanel.setLayout(null);
		rmPanel.setVisible(true);
		rmPanel.setBounds(380,60,500,500);
		rmPanel.setBackground(Color.cyan);
		
		
		bmPanel=new JPanel();
		bmPanel.setLayout(null);
		bmPanel.setVisible(false);
		bmPanel.setBounds(380,60,500,500);
		bmPanel.setBackground(Color.green);
		
		siPanel=new JPanel();
		siPanel.setLayout(null);
		siPanel.setVisible(false);
		siPanel.setBounds(380,60,500,500);
		siPanel.setBackground(Color.pink);
		
		sPanel=new JPanel();
		sPanel.setLayout(null);
		sPanel.setVisible(false);
		sPanel.setBounds(380,60,500,500);
		sPanel.setBackground(Color.magenta);
		
		smPanel=new JPanel();
		smPanel.setLayout(null);
		smPanel.setVisible(false);
		smPanel.setBounds(380,60,500,500);
		smPanel.setBackground(Color.yellow);
		
		rmMenu=new 	JMenu("客房管理");
		bmMenu=new JMenu("预定管理");
		siMenu=new 	JMenu("基础信息设置");
		sMenu=new 	JMenu("统计查询");
		smMenu=new 	JMenu("系统管理");
		ciItem=new JMenuItem("登记管理");cumItem=new JMenuItem("顾客消费");coItem=new JMenuItem("结账管理");
		bkItem=new JMenuItem("预定管理");bconItem=new JMenuItem("确定入住");bcelItem=new JMenuItem("解除预定");
		brItem=new JMenuItem("预定提醒"); clItem=new JMenuItem("消费品设置");rtItem=new JMenuItem("客房类型设置");
		riItem=new JMenuItem("客房信息管理");rsItem=new JMenuItem("客房状态查询");cirItem=new JMenuItem("历史住宿信息查询");
		crItem=new JMenuItem("收费记录查询");upItem=new JMenuItem("用户权限管理");exitItem=new JMenuItem("退出系统");
		
		rmButton=new JButton();
		rmButton.setBounds(55,30,80,60);
		rmButton.setIcon(new ImageIcon(rmButtonIcon));
		rmButton.setContentAreaFilled(false);
		rmButton.setHideActionText(true);
		rmButton.setBorderPainted(false);
		rmButton.setFocusable(false);
		rmLabel=new JLabel("客房管理");
		rmLabel.setBounds(170,150,60,20);
		rmLabel.setOpaque(true);
		rmLabel.setBackground(Color.orange);
		add(rmLabel);
		
		bmButton=new JButton();
		bmButton.setBounds(55,125,80,60);
		bmButton.setIcon(new ImageIcon(bmButtonIcon));
		bmButton.setContentAreaFilled(false);
		bmButton.setHideActionText(true);
		bmButton.setBorderPainted(false);
		bmButton.setFocusable(false);
		bmLabel=new JLabel("预定管理");
		bmLabel.setBounds(170,245,60,20);
		bmLabel.setOpaque(true);
		bmLabel.setBackground(Color.orange);
		add(bmLabel);
		
		
		
		
		siButton=new 	JButton();
		siButton.setBounds(55,215,80,60);
		siButton.setIcon(new ImageIcon(siButtonIcon));
		siButton.setContentAreaFilled(false);
		siButton.setHideActionText(true);
		siButton.setBorderPainted(false);
		siButton.setFocusable(false);
		siLabel=new JLabel("基础信息设置");
		siLabel.setBounds(170,335,60,20);
		siLabel.setOpaque(true);
		siLabel.setBackground(Color.orange);
		add(siLabel);
		
		
		
		sButton=new 	JButton();
		sButton.setBounds(55,305,80,60);
		sButton.setIcon(new ImageIcon(sButtonIcon));
		sButton.setContentAreaFilled(false);
		sButton.setHideActionText(true);
		sButton.setBorderPainted(false);
		sButton.setFocusable(false);
		sLabel=new JLabel("统计查询");
		sLabel.setBounds(170,425,60,20);
		sLabel.setOpaque(true);
		sLabel.setBackground(Color.orange);
		add(sLabel);
		
		
		
		smButton=new JButton();
		smButton.setBounds(55,395,80,60);
		smButton.setIcon(new ImageIcon(smButtonIcon));
		smButton.setContentAreaFilled(false);
		smButton.setHideActionText(true);
		smButton.setBorderPainted(false);
		smButton.setFocusable(false);
		smLabel=new JLabel("系统管理");
		smLabel.setBounds(170,515,60,20);
		smLabel.setOpaque(true);
		smLabel.setBackground(Color.orange);
		add(smLabel);
		
		
		
		
		ciButton=new JButton("");
		ciButton.setBounds(170,80,180,120);
		ciButton.setIcon(new ImageIcon(ciButtonIcon));
		ciButton.setContentAreaFilled(false);
		ciButton.setHideActionText(true);
		ciButton.setBorderPainted(false);
		ciButton.setFocusable(false);
		ciLabel=new JLabel("登记管理");
		ciLabel.setBounds(220,200,60,20);
		ciLabel.setOpaque(true);
		ciLabel.setBackground(Color.cyan);
		rmPanel.add(ciLabel);
		
		cumButton=new JButton("");
		cumButton.setBounds(45,280,180,120);
		cumButton.setIcon(new ImageIcon(cumButtonIcon));
		cumButton.setContentAreaFilled(false);
		cumButton.setHideActionText(true);
		cumButton.setBorderPainted(false);
		cumButton.setFocusable(false);
		cumLabel=new JLabel("顾客消费");
		cumLabel.setBounds(105,390,60,20);
		cumLabel.setOpaque(true);
		cumLabel.setBackground(Color.cyan);
		rmPanel.add(cumLabel);
		
		coButton=new JButton("");
		coButton.setBounds(290,280,180,120);
		coButton.setIcon(new ImageIcon(coButtonIcon));
		coButton.setContentAreaFilled(false);
		coButton.setHideActionText(true);
		coButton.setBorderPainted(false);
		coButton.setFocusable(false);
		coLabel=new JLabel("结账管理");
		coLabel.setBounds(345,390,60,20);
		coLabel.setOpaque(true);
		coLabel.setBackground(Color.cyan);
		rmPanel.add(coLabel);

		
		bkButton=new JButton("");
		bkButton.setBounds(65,100,160,110);
		bkButton.setIcon(new ImageIcon(bkButtonIcon));
		bkButton.setContentAreaFilled(false);
		bkButton.setHideActionText(true);
		bkButton.setBorderPainted(false);
		bkButton.setFocusable(false);
		bkLabel=new JLabel("预定登记");
		bkLabel.setBounds(120,210,60,20);
		bkLabel.setOpaque(true);
		bkLabel.setBackground(Color.green);
		bmPanel.add(bkLabel);
		
		bconButton=new JButton("");
		bconButton.setBounds(285,100,160,110);
		bconButton.setIcon(new ImageIcon(bconButtonIcon));
		bconButton.setContentAreaFilled(false);
		bconButton.setHideActionText(true);
		bconButton.setBorderPainted(false);
		bconButton.setFocusable(false);
		bconLabel=new JLabel("确定入住");
		bconLabel.setBounds(340,210,60,20);
		bconLabel.setOpaque(true);
		bconLabel.setBackground(Color.green);
		bmPanel.add(bconLabel);
		
		bcelButton=new JButton("");
		bcelButton.setBounds(65,270,160,110);
		bcelButton.setIcon(new ImageIcon(bcelButtonIcon));
		bcelButton.setContentAreaFilled(false);
		bcelButton.setHideActionText(true);
		bcelButton.setBorderPainted(false);
		bcelButton.setFocusable(false);
		bcelLabel=new JLabel("解除预定");
		bcelLabel.setBounds(120,375,60,20);
		bcelLabel.setOpaque(true);
		bcelLabel.setBackground(Color.green);
		bmPanel.add(bcelLabel);
		
		
		brButton=new JButton("");
		brButton.setBounds(285,270,160,110);
		brButton.setIcon(new ImageIcon(brButtonIcon));
		brButton.setContentAreaFilled(false);
		brButton.setHideActionText(true);
		brButton.setBorderPainted(false);
		brButton.setFocusable(false);
		brLabel=new JLabel("预定提醒");
		brLabel.setBounds(340,375,60,20);
		brLabel.setOpaque(true);
		brLabel.setBackground(Color.green);
		bmPanel.add(brLabel);
		
		
		clButton=new JButton("");
		clButton.setBounds(170,80,180,120);
		clButton.setIcon(new ImageIcon(clButtonIcon));
		clButton.setContentAreaFilled(false);
		clButton.setHideActionText(true);
		clButton.setBorderPainted(false);
		clButton.setFocusable(false);
		clLabel=new JLabel("消费品设置");
		clLabel.setBounds(220,200,100,20);
		clLabel.setOpaque(true);
		clLabel.setBackground(Color.pink);
		siPanel.add(clLabel);
		
		rtButton=new JButton("");
		rtButton.setBounds(55,275,180,120);
		rtButton.setIcon(new ImageIcon(rtButtonIcon));
		rtButton.setContentAreaFilled(false);
		rtButton.setHideActionText(true);
		rtButton.setBorderPainted(false);
		rtButton.setFocusable(false);
		rtLabel=new JLabel("客房类型设置");
		rtLabel.setBounds(105,398,100,20);
		rtLabel.setOpaque(true);
		rtLabel.setBackground(Color.pink);
		siPanel.add(rtLabel);
		
		riButton=new JButton("");
		riButton.setBounds(280,280,180,120);
		riButton.setIcon(new ImageIcon(riButtonIcon));
		riButton.setContentAreaFilled(false);
		riButton.setHideActionText(true);
		riButton.setBorderPainted(false);
		riButton.setFocusable(false);
		riLabel=new JLabel("客房信息管理");
		riLabel.setBounds(335,398,100,20);
		riLabel.setOpaque(true);
		riLabel.setBackground(Color.pink);
		siPanel.add(riLabel);
		
		
		rsButton=new JButton("");
		rsButton.setBounds(160,75,180,120);
		rsButton.setIcon(new ImageIcon(rsButtonIcon));
		rsButton.setContentAreaFilled(false);
		rsButton.setHideActionText(true);
		rsButton.setBorderPainted(false);
		rsButton.setFocusable(false);
		rsLabel=new JLabel("客房状态查询");
		rsLabel.setBounds(200,200,100,20);
		rsLabel.setOpaque(true);
		rsLabel.setBackground(Color.magenta);
		sPanel.add(rsLabel);
		
		cirButton=new JButton("");
		cirButton.setBounds(65,280,180,120);
		cirButton.setIcon(new ImageIcon(cirButtonIcon));
		cirButton.setContentAreaFilled(false);
		cirButton.setHideActionText(true);
		cirButton.setBorderPainted(false);
		cirButton.setFocusable(false);
		cirLabel=new JLabel("历史住宿信息查询");
		cirLabel.setBounds(95,398,120,20);
		cirLabel.setOpaque(true);
		cirLabel.setBackground(Color.magenta);
		sPanel.add(cirLabel);
		
		
		crButton=new JButton("");
		crButton.setBounds(280,280,180,120);
		crButton.setIcon(new ImageIcon(crButtonIcon));
		crButton.setContentAreaFilled(false);
		crButton.setHideActionText(true);
		crButton.setBorderPainted(false);
		crButton.setFocusable(false);
		crLabel=new JLabel("收费记录查询");
		crLabel.setBounds(335,398,100,20);
		crLabel.setOpaque(true);
		crLabel.setBackground(Color.magenta);
		sPanel.add(crLabel);
		
		
		
		upButton=new JButton("");
		upButton.setBounds(160,120,160,100);
		upButton.setIcon(new ImageIcon(upButtonIcon));
		upButton.setContentAreaFilled(false);
		upButton.setHideActionText(true);
		upButton.setBorderPainted(false);
		upButton.setFocusable(false);
		upLabel=new JLabel("用户权限管理");
		upLabel.setBounds(195,220,100,20);
		upLabel.setOpaque(true);
		upLabel.setBackground(Color.yellow);
		smPanel.add(upLabel);
		
		
		exitButton=new JButton("");
		exitButton.setBounds(160,260,160,100);
		exitButton.setIcon(new ImageIcon(exitButtonIcon));
		exitButton.setContentAreaFilled(false);
		exitButton.setHideActionText(true);
		exitButton.setBorderPainted(false);
		exitButton.setFocusable(false);
		exitLabel=new JLabel("退出系统");
		exitLabel.setBounds(205,360,100,20);
		exitLabel.setOpaque(true);
		exitLabel.setBackground(Color.yellow);
		smPanel.add(exitLabel);
		
		
		
		
		
		timeLabel=new Label();
		timeLabel.setForeground(Color.black);
		timeLabel.setBounds(875,630,150,20);
		timeLabel.setVisible(true);
		add(timeLabel);
		

		
		
		mainBar.add(rmMenu); mainBar.add(bmMenu); mainBar.add(siMenu); mainBar.add(sMenu);mainBar.add(smMenu);
		rmMenu.add(ciItem); rmMenu.add(cumItem); rmMenu.add(coItem);
		bmMenu.add(bkItem); bmMenu.add(bconItem);bmMenu.add(bcelItem);bmMenu.add(brItem);
		siMenu.add(clItem);siMenu.add(rtItem);siMenu.add(riItem);
		sMenu.add(rsItem); sMenu.add(cirItem); sMenu.add(crItem);
		smMenu.add(upItem);smMenu.add(exitItem);
		add(rmPanel);add(bmPanel);add(siPanel);add(sPanel);add(smPanel);

		selectPanel.add(rmButton);selectPanel.add(bmButton);selectPanel.add(siButton);selectPanel.add(sButton);selectPanel.add(smButton);
		rmPanel.add(ciButton);rmPanel.add(cumButton);rmPanel.add(coButton);
		bmPanel.add(bkButton);bmPanel.add(bconButton);bmPanel.add(bcelButton);bmPanel.add(brButton);
		siPanel.add(clButton);siPanel.add(rtButton);siPanel.add(riButton);
		sPanel.add(rsButton);sPanel.add(cirButton);sPanel.add(crButton);
		smPanel.add(upButton);smPanel.add(exitButton);
		add(rmPanel);add(bmPanel);add(siPanel);add(sPanel);add(smPanel);add(selectPanel);
	
		rmButton.addActionListener(this);  bmButton.addActionListener(this);
		siButton.addActionListener(this);  sButton.addActionListener(this);
		smButton.addActionListener(this);  ciButton.addActionListener(this);
		cumButton.addActionListener(this);  coButton.addActionListener(this);
		bkButton.addActionListener(this);  bconButton.addActionListener(this);
		bcelButton.addActionListener(this);  brButton.addActionListener(this);
		clButton.addActionListener(this);  rtButton.addActionListener(this);
		riButton.addActionListener(this);  rsButton.addActionListener(this);
		cirButton.addActionListener(this);  crButton.addActionListener(this);
		upButton.addActionListener(this); exitButton.addActionListener(this);
		
		ciItem.addActionListener(this);cumItem.addActionListener(this);
		coItem.addActionListener(this);bkItem.addActionListener(this);
		bconItem.addActionListener(this);bcelItem.addActionListener(this);
		brItem.addActionListener(this);clItem.addActionListener(this);
		rtItem.addActionListener(this);riItem.addActionListener(this);
		rsItem.addActionListener(this);cirItem.addActionListener(this);
		crItem.addActionListener(this);upItem.addActionListener(this);
		exitItem.addActionListener(this);
	}

	 
	
	
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==rmButton){
			rmPanel.setVisible(true);
			bmPanel.setVisible(false);
			siPanel.setVisible(false);
			sPanel.setVisible(false);
			smPanel.setVisible(false);
		}
		if(e.getSource()==bmButton){
			rmPanel.setVisible(false);
			bmPanel.setVisible(true);
			siPanel.setVisible(false);
			sPanel.setVisible(false);
			smPanel.setVisible(false);
		}
		if(e.getSource()==siButton){
			rmPanel.setVisible(false);
			bmPanel.setVisible(false);
			siPanel.setVisible(true);
			sPanel.setVisible(false);
			smPanel.setVisible(false);
		}
		if(e.getSource()==sButton){
			rmPanel.setVisible(false);
			bmPanel.setVisible(false);
			siPanel.setVisible(false);
			sPanel.setVisible(true);
			smPanel.setVisible(false);
		}
		if(e.getSource()==smButton){
			rmPanel.setVisible(false);
			bmPanel.setVisible(false);
			siPanel.setVisible(false);
			sPanel.setVisible(false);
			smPanel.setVisible(true);
		}
		if(e.getSource()==ciButton){
			
	
		}
		if(e.getSource()==cumButton){
			
		}
		if(e.getSource()==coButton){
			
		}
		if(e.getSource()==bkButton){
			
		}
		if(e.getSource()==bconButton){
			
		}
		if(e.getSource()==bcelButton){
			
		}
		if(e.getSource()==brButton){
			
		}
		if(e.getSource()==clButton){
			
		}
		if(e.getSource()==rtButton){
			new RoomTypeFrame(this,true);
		}
		if(e.getSource()==riButton){
			
		}
		if(e.getSource()==rsButton){
			
		}
		if(e.getSource()==cirButton){
			
		}
		if(e.getSource()==crButton){
			
		}
		if(e.getSource()==upButton){
			AdminFrame frame = new AdminFrame(this,true);
			frame.setVisible(true);
		}
		if(e.getSource()==exitButton){
			setVisible(false);
			System.exit(0);
		}
		
		if(e.getSource()==ciItem){
			
		}
		if(e.getSource()==cumItem){
			
		}
		if(e.getSource()==coItem){
			
		}
		if(e.getSource()==bkItem){
			
		}
		if(e.getSource()==bconItem){
			
		}
		if(e.getSource()==bcelItem){
			
		}
		if(e.getSource()==brItem){
			
		}
		if(e.getSource()==clItem){
			new ProuduceManger(this,true); 
		}
		if(e.getSource()==rtItem){
			new RoomTypeFrame(this,true);
		}
		if(e.getSource()==riItem){
			
		}
		if(e.getSource()==rsItem){
			
		}
		if(e.getSource()==cirItem){
			
		}
		if(e.getSource()==crItem){
			
		}
		if(e.getSource()==upItem){
			AdminFrame frame = new AdminFrame(this,true);
			frame.setVisible(true);
		}
		if(e.getSource()==exitItem){
			setVisible(false);
			System.exit(0);
		}
		
		
	}
static class Clock  implements Runnable{
	public Clock(){
		flush();
		ExecutorService exec=Executors.newCachedThreadPool();
		exec.execute(this);
	}
	private void flush(){
		String strTime=String.format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		timeLabel.setText(strTime);
	}
	public void run(){
		while(true){
			flush();
				try{
					Thread.sleep(1000);
				}
				catch(Exception e){
					
				}
		}
	}
}
}
